<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	
<h:head>
	<h:outputStylesheet library="css" name="main.css" />
</h:head>
<h:body>
<ui:composition template="/template/default.xhtml">
	<ui:define name="no_form">
	<h:outputScript name="locales.js" library="js"/> 
	<h:form>
		<fieldset class="container">
			<legend>${msgs.mensagemInicial}</legend>
	
		<h:panelGrid columns="2">
		
		<h:outputLabel for="dataInicial" value="#{msgs.dataInicial}" />
		<p:calendar id="dataInicial"  
			showOn="button" 
			pattern="dd/MM/yyyy" 
			locale="pt_BR" 
			required="false"
			value="#{relatoriosMB.dataInicial}"
			/>
		
		
		<h:outputLabel for="dataFinal" value="#{msgs.dataFinal}" />
		<p:calendar id="dataFinal"  
			showOn="button" 
			pattern="dd/MM/yyyy" 
			locale="pt_BR" 
			required="false"
			value="#{relatoriosMB.dataFinal}"
			/>
		
		
		<p:outputLabel value="Paciente:" for="paciente" />  
        <p:autoComplete 
            	id="paciente" 
            	dropdown="true"
            	forceSelection="true"
                completeMethod="#{relatoriosMB.pacienteAutocomplete}"
                maxResults="10"
                minQueryLength="3"
                size="120"
                var="paciente"
                itemLabel="#{paciente.autocomplete}"
                itemValue="#{paciente}"
                required="false"
                value="#{relatoriosMB.paciente}"
         />  
        
        </h:panelGrid>
        
        <br/>
         
        <h:commandButton action="#{relatoriosMB.filtarPorDatasPaciente()}" value="#{msgs.filtrar}"/>
        
        <br/>
        
        <p:dataTable var="registro" value="#{relatoriosMB.lazyModel}" paginator="true" rows="10"
                 paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                 rowsPerPageTemplate="5,10,15,25,50" id="dataTable" lazy="true">

	        <p:column headerText="#{msgs.nomePaciente}">
	            <h:outputText value="#{registro.nome}" />
	        </p:column>
	
	        <p:column headerText="#{msgs.prontuario}">
	            <h:outputText value="#{registro.prontuario}" />
	        </p:column>
	
	        <p:column headerText="#{msgs.identificacao}">
	            <h:outputText value="#{registro.identificacao}" />
	        </p:column>
	
	        <p:column headerText="#{msgs.criadoPor}" sortBy="#{registro.usuarioDaSessao.nome}" rendered="#{userMB.isUserAdmin()}">
	            <h:outputText value="#{registro.criadoPor}" />
	        </p:column>
	        
	        <p:column headerText="#{msgs.tipo}" sortBy="#{registro.tipo}">
	            <h:outputText value="#{registro.tipo}" />
	        </p:column>
			
			<p:column headerText="#{msgs.dataDeCriacao}" sortBy="#{registro.dataDeCriacao}">
	            <h:outputText value="#{registro.dataDeCriacao}">
				<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" 
					type="date" locale="pt_BR" timeZone="America/Fortaleza"/>
				</h:outputText>
	        </p:column>
	        
	        <p:column headerText="#{msgs.segundaVia}">
				<h:commandLink action="#{relatoriosMB.segundaViaRelatorio(registro.id)}" 
					oncomplete="javascript:NovaJanela('#{request.contextPath}/gerarSegundaViaRelatorio','nomeJanela','450','450','yes');return false;">
					<h:graphicImage library="images" name="pdf3.png" height="20" width="20" />
				</h:commandLink>
			</p:column>
			
		</p:dataTable>
		</fieldset>
	</h:form>
	</ui:define>
</ui:composition>	
</h:body>
</html>